<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>结算操作页面</title>
    <link rel="stylesheet" href="../layui/css/layui.css" media="all">
    <!--<link rel="stylesheet" href="../layui/css/admin.css" media="all"/>-->
    <style>
        .layui-form-label {
            width: 100px;
        }
        .layui-form-item {
            margin-top: 10px;
        }
        .layui-disabled {
            color: black!important;
        }
        .lform {
            width: 300px;
        }
        .sform {
            width: 100px;
        }
    </style>
</head>
<body>
<input id="hidValue" type="hidden">
<form class="layui-form" id="addForm" style="padding-top: 20px;">
    <input id="grmid" name="grmid" type="hidden">
    <div class="layui-form-item layui-inline" style="margin-bottom: 0px;">
        <label class="layui-form-label">差错主id</label>
        <div class="layui-inline">
            <input id="aid" class="layui-input lform layui-disabled" readonly="readonly"/>
        </div>
    </div>
    <div class="layui-form-item layui-inline" style="margin-bottom: 0px;">
        <label class="layui-form-label">货运回执单编号</label>
        <div class="layui-inline">
            <input id="goodsRevertBillcode" class="layui-input layui-disabled" readonly="readonly"/>
        </div>
    </div>
    <div class="layui-form-item layui-inline" style="margin-bottom: 0px;">
        <label class="layui-form-label">客户名称</label>
        <div class="layui-inline">
            <input id="customer" class="layui-input "  type="text"/>
        </div>
    </div>
    <div class="layui-form-item layui-inline" style="margin-bottom: 0px;">
        <label class="layui-form-label">货物名称</label>
        <div class="layui-inline">
            <input id="goodsName" name="goodsName" class="layui-input" type="text" placeholder="请输入" />
        </div>
    </div>
    <div class="layui-form-item layui-inline" style="margin-bottom: 0px;">
        <label class="layui-form-label">差错说明</label>
        <div class="layui-inline">
            <input id="mistakeExplain" class="layui-input " type="text"  placeholder="请输入"/>
        </div>
    </div>
    <div class="layui-form-item text-right" style="margin-top: 20px;text-align: center;">
            <button class="layui-btn" lay-filter="addSubmit" lay-submit>保存</button>
            <button class="layui-btn layui-btn-primary" id="closebutton" type="button" >取消</button>
    </div><!--ew-event="closeDialog"-->
</form>
<script src="../layui/layui.js" charset="utf-8"></script>
<script>
    // 要使用的layui模块
    layui.use(['layer', 'form', 'laydate'], function () {
        var layer = layui.layer; // 获得layer模块
        var form = layui.form; // 获得form模块
        var laydate = layui.laydate; // 获得laydate模块
        var $ = layui.$; // 调用JQuery方法时

        // 表单赋值
        // var adddata = JSON.parse($("#hidValue").val());
        // $('#grmid').val(adddata.grmid);
        // $('#goodsRevertBillCode').val(adddata.goodsRevertBillCode);
        // $('#allCarriage').val(adddata.allCarriage);
        // $('#insurance').val(adddata.insurance);
        // $('#linkmanPhone').val(adddata.linkmanPhone);
        // $('#driverInformation').val(adddata.driverInformation.driverName);
        // //var value = Math.round((adddata.insurance*adddata.driverInformation) * 100)/100;
        // //var ifBalance = value>25?value:25;
        // $('#ifBalance').val(adddata.ifBalance);
        // $('#checkGoodsReceive').val(adddata.checkGoodsReceive.status);

        // 弹窗
      /*  layer.tips('已自动填充', '#linkmanPhone', {
            tips: [2, '#3595CC'],
            tipsMore: true,
            time: 2000
        });
        layer.tips('已自动填充', '#checkGoodsReceive', {
            tips: [2, '#3595CC'],
            tipsMore: true,
            time: 2000
        });
 */
        // 监听关闭
        $('#closebutton').click(function () {
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        })


        // 监听提交
        form.on('submit(addSubmit)', function(data) {
            var index = parent.layer.getFrameIndex(window.name);

            // alert(JSON.stringify(data.field.goodsRevertBillCode));
            // alert(data.field.goodsRevertBillCode);
            //console.log(data.elem) //被执行事件的元素DOM对象，一般为button对象
            //console.log(data.form) //被执行提交的form对象，一般在存在form标签时才会返回
           // console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}
            $.ajax({
                url: 'http://localhost:8080/modifyArriveError',
                type: 'post',
                dataType: 'json',
                data: {
					"aid":  $('#aid').val(),
                    "goodsRevertBillcode":  $('#goodsRevertBillcode').val(),
                    "customer": $('#customer').val(),
					"goodsName": $('#goodsName').val(),
					"mistakeExplain": $('#mistakeExplain').val()
                },
                success: function(result) {
                    if(result.msg.indexOf("成功") == -1){
                        layer.msg(result.msg, {
                            icon: 1,
                            time: 1500
                        })
						 setTimeout(function() {
							 	parent.location.reload();
						    /* 关闭弹出层 */
						    parent.layer.close(index);
						    /* 刷新父页面中的表格 */
							parent.location.reload();
						}, 2000);
                    }else{
                        layer.msg(result.msg, {
                            icon: 1,
                            time: 1500
                        });
                        setTimeout(function() {
                            /* 关闭弹出层 */
                            parent.layer.close(index);
                            /* 刷新父页面中的表格 */
                            parent.layui.table.reload('table');
                            /* 刷新父页面 */
                            parent.location.reload();
                        }, 2000);
                    }
                    /*layer.msg(result.msg, {
                        icon: 1,
                        time: 2000
                    });

                    setTimeout(function() {
                        parent.layer.close(index);
                    }, 1000);

                    setTimeout(function() {
                        location.reload();
                    }, 1000);*/
                }
            })
            return false;
        });
    });
</script>
</body>
</html>